<!DOCTYPE html>


<html lang="zn-CH">


<head>
  <meta charset="utf-8" />
    
  <meta name="description" content="What I can do is to Do My Personal Best!" />
  
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
  <title>
    Python 常用的工具包(后期继续完善) |  小熊的博客
  </title>
  <meta name="generator" content="hexo-theme-yilia-plus">
  
  <link rel="shortcut icon" href="http://www.cdn.adingxiong.com/b5363a06dc744d79a94021492bcefe27" />
  
  
<link rel="stylesheet" href="/blog/dist/main.css">

  
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/Shen-Yu/cdn/css/remixicon.min.css">

  
<link rel="stylesheet" href="/blog/css/custom.css">

  
  
<script src="https://cdn.jsdelivr.net/npm/pace-js@1.0.2/pace.min.js"></script>

  
  

  

<link rel="alternate" href="/blog/atom.xml" title="小熊的博客" type="application/atom+xml">
</head>

</html>

<body>
  <div id="app">
    <main class="content on">
      <section class="outer">
  <article id="post-Python-常用的工具包-后期继续完善" class="article article-type-post" itemscope
  itemprop="blogPost" data-scroll-reveal>

  <div class="article-inner">
    
    <header class="article-header">
       
<h1 class="article-title sea-center" style="border-left:0" itemprop="name">
  Python 常用的工具包(后期继续完善)
</h1>
 

    </header>
    

    
    <div class="article-meta">
      <a href="/blog/2020/09/14/Python-%E5%B8%B8%E7%94%A8%E7%9A%84%E5%B7%A5%E5%85%B7%E5%8C%85-%E5%90%8E%E6%9C%9F%E7%BB%A7%E7%BB%AD%E5%AE%8C%E5%96%84/" class="article-date">
  <time datetime="2020-09-14T09:49:27.000Z" itemprop="datePublished">2020-09-14</time>
</a>
      
      
      
<div class="word_count">
    <span class="post-time">
        <span class="post-meta-item-icon">
            <i class="ri-quill-pen-line"></i>
            <span class="post-meta-item-text"> Word count:</span>
            <span class="post-count">587</span>
        </span>
    </span>

    <span class="post-time">
        &nbsp; | &nbsp;
        <span class="post-meta-item-icon">
            <i class="ri-book-open-line"></i>
            <span class="post-meta-item-text"> Reading time≈</span>
            <span class="post-count">2 min</span>
        </span>
    </span>
</div>

      
    </div>
    

    
    
    <div class="tocbot"></div>





    

    
    <div class="article-entry" itemprop="articleBody">
      
      

      
      <section id="nice" data-tool="mdnice编辑器" data-website="https://www.mdnice.com" style="font-size: 16px; color: black; padding: 0 10px; line-height: 1.6; word-spacing: 0px; letter-spacing: 0px; word-break: break-word; word-wrap: break-word; text-align: left; font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, 'PingFang SC', Cambria, Cochin, Georgia, Times, 'Times New Roman', serif;"><h1 data-tool="mdnice编辑器" style="margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; font-size: 1.8em; color: #009688; margin: 1.2em auto; text-align: center; border-bottom: 1px solid #009688;"><span class="prefix" style="display: none;"></span><span class="content">Python 常用的工具包(后期继续完善)</span><span class="suffix"></span></h1>
<p data-tool="mdnice编辑器" style="font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black; text-align: justify;"><strong style="font-weight: bold; color: black;">提示: 如果引入包之后报错,检查一下缩进,python对代码缩进规范要求比较高</strong></p>
<h3 data-tool="mdnice编辑器" style="margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 20px; margin: 0.6em auto; padding-left: 10px; border-left: 2px solid #009688;"><span class="prefix" style="display: none;"></span><span class="content">工具类</span><span class="suffix" style="display: none;"></span></h3>
<ul data-tool="mdnice编辑器" style="margin-top: 8px; margin-bottom: 8px; padding-left: 25px; color: black; list-style-type: disc;">
<li><section style="margin-top: 5px; margin-bottom: 5px; line-height: 26px; text-align: left; color: rgb(1,1,1); font-weight: 500;">图片下载</section></li><li><section style="margin-top: 5px; margin-bottom: 5px; line-height: 26px; text-align: left; color: rgb(1,1,1); font-weight: 500;">文件写入</section></li><li><section style="margin-top: 5px; margin-bottom: 5px; line-height: 26px; text-align: left; color: rgb(1,1,1); font-weight: 500;">数据导出</section></li></ul>
<pre class="custom" data-tool="mdnice编辑器" style="margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;"><span style="display: block; background: url(https://my-wechat.mdnice.com/point.png); height: 30px; width: 100%; background-size: 40px; background-repeat: no-repeat; background-color: #fafafa; margin-bottom: -7px; border-radius: 5px; background-position: 10px 10px;"></span><code class="hljs" style="overflow-x: auto; padding: 16px; color: #383a42; display: block; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #fafafa; border-radius: 5px;"><span class="hljs-string" style="color: #50a14f; line-height: 26px;">"""
<span>    descripte:   工具包相关
<span>    Date:  2020年9月14日16:28:51
<span>    author： xiongchao
<span>"""</span>
<span><span class="hljs-keyword" style="color: #a626a4; line-height: 26px;">import</span> os
<span><span class="hljs-keyword" style="color: #a626a4; line-height: 26px;">import</span> threading
<span><span class="hljs-keyword" style="color: #a626a4; line-height: 26px;">import</span> json
<span><span class="hljs-keyword" style="color: #a626a4; line-height: 26px;">import</span> requests
<span><span class="hljs-keyword" style="color: #a626a4; line-height: 26px;">from</span> openpyxl <span class="hljs-keyword" style="color: #a626a4; line-height: 26px;">import</span> Workbook
<span>
<span>
<span><span class="hljs-class" style="line-height: 26px;"><span class="hljs-keyword" style="color: #a626a4; line-height: 26px;">class</span> <span class="hljs-title" style="color: #c18401; line-height: 26px;">pyUtils</span>:</span>
<span>
<span>    <span class="hljs-string" style="color: #50a14f; line-height: 26px;">"""
<span>        函数说明: 图片下载
<span>        Parameters:
<span>            urlList :[
<span>                {
<span>                    url:"http://example.com/img/url/download...',
<span>                    name:"图片名称
<span>                }
<span>            ],
<span>            path : 下载路径
<span>        Returns:
<span>            file: 下载文件到指定路径
<span>    """</span>
<span>
<span>    <span class="hljs-function" style="line-height: 26px;"><span class="hljs-keyword" style="color: #a626a4; line-height: 26px;">def</span> <span class="hljs-title" style="color: #4078f2; line-height: 26px;">download</span><span class="hljs-params" style="line-height: 26px;">(url, name, path)</span>:</span>
<span>        <span class="hljs-keyword" style="color: #a626a4; line-height: 26px;">try</span>:
<span>            print(<span class="hljs-string" style="color: #50a14f; line-height: 26px;">'开始下载:'</span>, name)
<span>            content = requests.get(url).content
<span>            path = <span class="hljs-string" style="color: #50a14f; line-height: 26px;">'%s/%s.jpg'</span> % (path, name)
<span>            <span class="hljs-keyword" style="color: #a626a4; line-height: 26px;">with</span> open(path, <span class="hljs-string" style="color: #50a14f; line-height: 26px;">'wb'</span>) <span class="hljs-keyword" style="color: #a626a4; line-height: 26px;">as</span> f:
<span>                f.write(content)
<span>            print(<span class="hljs-string" style="color: #50a14f; line-height: 26px;">'下载完成'</span>, name)
<span>        <span class="hljs-keyword" style="color: #a626a4; line-height: 26px;">except</span>:
<span>            print(<span class="hljs-string" style="color: #50a14f; line-height: 26px;">"Error: system error,please try again later "</span>)
<span>
<span>    <span class="hljs-function" style="line-height: 26px;"><span class="hljs-keyword" style="color: #a626a4; line-height: 26px;">def</span> <span class="hljs-title" style="color: #4078f2; line-height: 26px;">img_download</span><span class="hljs-params" style="line-height: 26px;">(urlList, path)</span>:</span>
<span>        <span class="hljs-keyword" style="color: #a626a4; line-height: 26px;">if</span> path:
<span>            <span class="hljs-keyword" style="color: #a626a4; line-height: 26px;">if</span> <span class="hljs-keyword" style="color: #a626a4; line-height: 26px;">not</span> os.path.exists(path):
<span>                os.mkdir(path)
<span>                print(<span class="hljs-string" style="color: #50a14f; line-height: 26px;">"文件夹{}创建成功"</span>.format(path))
<span>
<span>        <span class="hljs-keyword" style="color: #a626a4; line-height: 26px;">if</span> urlList:
<span>            <span class="hljs-keyword" style="color: #a626a4; line-height: 26px;">for</span> list <span class="hljs-keyword" style="color: #a626a4; line-height: 26px;">in</span> urlList:
<span>                print(<span class="hljs-string" style="color: #50a14f; line-height: 26px;">"下载地址为"</span>, list[<span class="hljs-string" style="color: #50a14f; line-height: 26px;">'url'</span>])
<span>                threading.Thread(target=pyUtils.download, args=(
<span>                    list[<span class="hljs-string" style="color: #50a14f; line-height: 26px;">'url'</span>], list[<span class="hljs-string" style="color: #50a14f; line-height: 26px;">'name'</span>], path)).start()
<span>
<span>    <span class="hljs-string" style="color: #50a14f; line-height: 26px;">""" 
<span>        函数说明: 文本写入
<span>        Parameters:
<span>            name: 标题
<span>            path: 保存的路径  
<span>            text: 要写入的问题内容
<span>        Returns:
<span>            file: 下载文件到指定路径
<span>    """</span>
<span>    <span class="hljs-function" style="line-height: 26px;"><span class="hljs-keyword" style="color: #a626a4; line-height: 26px;">def</span> <span class="hljs-title" style="color: #4078f2; line-height: 26px;">write</span><span class="hljs-params" style="line-height: 26px;">(name, path, text)</span>:</span>
<span>    <span class="hljs-comment" style="color: #a0a1a7; font-style: italic; line-height: 26px;"># 第二个参数  数据 a  标识追加写入  </span>
<span>        <span class="hljs-keyword" style="color: #a626a4; line-height: 26px;">try</span>:
<span>            <span class="hljs-keyword" style="color: #a626a4; line-height: 26px;">if</span> <span class="hljs-keyword" style="color: #a626a4; line-height: 26px;">not</span> text:
<span>                <span class="hljs-keyword" style="color: #a626a4; line-height: 26px;">with</span> open(path, <span class="hljs-string" style="color: #50a14f; line-height: 26px;">'a'</span>, encoding=<span class="hljs-string" style="color: #50a14f; line-height: 26px;">'utf-8'</span>) <span class="hljs-keyword" style="color: #a626a4; line-height: 26px;">as</span> f:
<span>                    f.write(name + <span class="hljs-string" style="color: #50a14f; line-height: 26px;">'\n'</span>)
<span>                    f.writelines(text)
<span>                    f.write(<span class="hljs-string" style="color: #50a14f; line-height: 26px;">'\n\n'</span>)
<span>                    print(<span class="hljs-string" style="color: #50a14f; line-height: 26px;">"文件{}.txt,写入完成"</span>.format(<span class="hljs-keyword" style="color: #a626a4; line-height: 26px;">print</span>))
<span>        <span class="hljs-keyword" style="color: #a626a4; line-height: 26px;">except</span>:
<span>            print(<span class="hljs-string" style="color: #50a14f; line-height: 26px;">"数据写入失败"</span>)
<span>
<span>    <span class="hljs-string" style="color: #50a14f; line-height: 26px;">"""  
<span>        函数说明: 数据导出
<span>        Parameters:
<span>            name: 文件名+ 保存路径    ../demo/文件导出.xlsx
<span>            header: 表头  
<span>            content: 数据
<span>    """</span>
<span>    <span class="hljs-function" style="line-height: 26px;"><span class="hljs-keyword" style="color: #a626a4; line-height: 26px;">def</span> <span class="hljs-title" style="color: #4078f2; line-height: 26px;">excel_import</span><span class="hljs-params" style="line-height: 26px;">(name, header, content)</span>:</span>
<span>        <span class="hljs-comment" style="color: #a0a1a7; font-style: italic; line-height: 26px;"># 创建 文件对象</span>
<span>        wb = Workbook()
<span>        <span class="hljs-comment" style="color: #a0a1a7; font-style: italic; line-height: 26px;"># 新建一个表</span>
<span>        ws = wb.active
<span>        <span class="hljs-comment" style="color: #a0a1a7; font-style: italic; line-height: 26px;"># 设置表头</span>
<span>        <span class="hljs-keyword" style="color: #a626a4; line-height: 26px;">if</span> header:
<span>            <span class="hljs-keyword" style="color: #a626a4; line-height: 26px;">for</span> row <span class="hljs-keyword" style="color: #a626a4; line-height: 26px;">in</span> range(len(header)):
<span>                c = row + <span class="hljs-number" style="color: #986801; line-height: 26px;">1</span>
<span>                ws.cell(row=<span class="hljs-number" style="color: #986801; line-height: 26px;">1</span>, column=c, value=header[row])
<span>        <span class="hljs-keyword" style="color: #a626a4; line-height: 26px;">else</span>:
<span>            print(<span class="hljs-string" style="color: #50a14f; line-height: 26px;">"header 为空"</span>)
<span>        <span class="hljs-comment" style="color: #a0a1a7; font-style: italic; line-height: 26px;"># 填写表中内容</span>
<span>        <span class="hljs-keyword" style="color: #a626a4; line-height: 26px;">if</span> content:
<span>
<span>            <span class="hljs-keyword" style="color: #a626a4; line-height: 26px;">for</span> listIndex <span class="hljs-keyword" style="color: #a626a4; line-height: 26px;">in</span> range(len(content)):
<span>                ws.append(content[listIndex])
<span>
<span>            wb.save(filename=data_fileName)
<span>            print(<span class="hljs-string" style="color: #50a14f; line-height: 26px;">"写入成功"</span>)
<span>        <span class="hljs-keyword" style="color: #a626a4; line-height: 26px;">else</span>:
<span>            print(<span class="hljs-string" style="color: #50a14f; line-height: 26px;">"没有数据"</span>)
<span>
<span>
<span>
<span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></code></pre>
<h3 data-tool="mdnice编辑器" style="margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 20px; margin: 0.6em auto; padding-left: 10px; border-left: 2px solid #009688;"><span class="prefix" style="display: none;"></span><span class="content">测试</span><span class="suffix" style="display: none;"></span></h3>
<pre class="custom" data-tool="mdnice编辑器" style="margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;"><span style="display: block; background: url(https://my-wechat.mdnice.com/point.png); height: 30px; width: 100%; background-size: 40px; background-repeat: no-repeat; background-color: #fafafa; margin-bottom: -7px; border-radius: 5px; background-position: 10px 10px;"></span><code class="hljs" style="overflow-x: auto; padding: 16px; color: #383a42; display: block; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #fafafa; border-radius: 5px;"><span class="hljs-comment" style="color: #a0a1a7; font-style: italic; line-height: 26px;"># 导入自己写的工具包</span>
<span><span class="hljs-keyword" style="color: #a626a4; line-height: 26px;">from</span> pyUtils <span class="hljs-keyword" style="color: #a626a4; line-height: 26px;">import</span> pyUtils
<span>
<span>urlList = [
<span>    {<span class="hljs-string" style="color: #50a14f; line-height: 26px;">'url'</span>: <span class="hljs-string" style="color: #50a14f; line-height: 26px;">'https://www.logosc.cn/uploads/icon/2019/06/14//54538bb3-706b-40f6-bc20-63a5350b4909.png'</span>, <span class="hljs-string" style="color: #50a14f; line-height: 26px;">'name'</span>: <span class="hljs-string" style="color: #50a14f; line-height: 26px;">'火焰logo图片.png'</span>}, 
<span>    {<span class="hljs-string" style="color: #50a14f; line-height: 26px;">'url'</span>: <span class="hljs-string" style="color: #50a14f; line-height: 26px;">'https://www.logosc.cn/uploads/icon/2019/06/14//8a748e3a-faa9-4c8e-bbdb-3c535cdc60d3.png'</span>, <span class="hljs-string" style="color: #50a14f; line-height: 26px;">'name'</span>: <span class="hljs-string" style="color: #50a14f; line-height: 26px;">'音乐琴行logo.png'</span>},
<span>    {<span class="hljs-string" style="color: #50a14f; line-height: 26px;">'url'</span>: <span class="hljs-string" style="color: #50a14f; line-height: 26px;">'https://www.logosc.cn/uploads/icon/2019/06/14//7f3daa30-da19-46c4-9591-cd3b73205b7d.png'</span>, <span class="hljs-string" style="color: #50a14f; line-height: 26px;">'name'</span>: <span class="hljs-string" style="color: #50a14f; line-height: 26px;">'狼咆哮logo图标'</span>},
<span>    {<span class="hljs-string" style="color: #50a14f; line-height: 26px;">'url'</span>: <span class="hljs-string" style="color: #50a14f; line-height: 26px;">'https://www.logosc.cn/uploads/icon/2019/06/14//a2fecd51-1b09-47d6-b797-3e71cbdd4a4a.png'</span>, <span class="hljs-string" style="color: #50a14f; line-height: 26px;">'name'</span>: <span class="hljs-string" style="color: #50a14f; line-height: 26px;">'音乐符号logo图标.png'</span>}
<span>]
<span>
<span>pyUtils.img_download(urlList,<span class="hljs-string" style="color: #50a14f; line-height: 26px;">"下载"</span>)
<span>
<span>
<span>
<span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></code></pre>
<figure data-tool="mdnice编辑器" style="margin: 0; margin-top: 10px; margin-bottom: 10px; display: flex; flex-direction: column; justify-content: center; align-items: center;"><img src="https://p6-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/0220e276fd0a4886829d4412e9b986ef~tplv-k3u1fbpfcp-zoom-1.image" alt style="display: block; margin: 0 auto; max-width: 100%;"></figure>
<figure data-tool="mdnice编辑器" style="margin: 0; margin-top: 10px; margin-bottom: 10px; display: flex; flex-direction: column; justify-content: center; align-items: center;"><img src="https://p1-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/7deabe7d16b44f519a15fb4e49cec2c3~tplv-k3u1fbpfcp-zoom-1.image" alt style="display: block; margin: 0 auto; max-width: 100%;"></figure>
<figure data-tool="mdnice编辑器" style="margin: 0; margin-top: 10px; margin-bottom: 10px; display: flex; flex-direction: column; justify-content: center; align-items: center;"><img src="https://p1-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/0e7869f6e79f431d9752a43278c883f5~tplv-k3u1fbpfcp-zoom-1.image" alt style="display: block; margin: 0 auto; max-width: 100%;"></figure>
<p id="nice-suffix-juejin-container" class="nice-suffix-juejin-container" data-tool="mdnice编辑器" style="font-size: 16px; padding-top: 8px; padding-bottom: 8px; margin: 0; line-height: 26px; color: black; text-align: justify; margin-top: 20px !important;">本文使用 <a href="https://mdnice.com/?from=juejin" target="_blank" rel="noopener" style="text-decoration: none; word-wrap: break-word; font-weight: bold; color: #009688; border-bottom: 1px solid #009688;">mdnice</a> 排版</p></section>

<p>我的博客即将同步至腾讯云+社区，邀请大家一同入驻：<a href="https://cloud.tencent.com/developer/support-plan?invite_code=1yz96un93ccgw" target="_blank" rel="noopener">https://cloud.tencent.com/developer/support-plan?invite_code=1yz96un93ccgw</a></p>

      
      <!-- reward -->
      
      <div id="reward-btn">
        Donate
      </div>
      
    </div>
    
    
      <!-- copyright -->
      
        <div class="declare">
          <ul class="post-copyright">
            <li>
              <i class="ri-copyright-line"></i>
              <strong>Copyright： </strong>
              Copyright is owned by the author. For commercial reprints, please contact the author for authorization. For non-commercial reprints, please indicate the source.
            </li>
          </ul>
        </div>
        
    <footer class="article-footer">
      
          
<div class="share-btn">
      <span class="share-sns share-outer">
        <i class="ri-share-forward-line"></i>
        分享
      </span>
      <div class="share-wrap">
        <i class="arrow"></i>
        <div class="share-icons">
          
          <a class="weibo share-sns" href="javascript:;" data-type="weibo">
            <i class="ri-weibo-fill"></i>
          </a>
          <a class="weixin share-sns wxFab" href="javascript:;" data-type="weixin">
            <i class="ri-wechat-fill"></i>
          </a>
          <a class="qq share-sns" href="javascript:;" data-type="qq">
            <i class="ri-qq-fill"></i>
          </a>
          <a class="douban share-sns" href="javascript:;" data-type="douban">
            <i class="ri-douban-line"></i>
          </a>
          <!-- <a class="qzone share-sns" href="javascript:;" data-type="qzone">
            <i class="icon icon-qzone"></i>
          </a> -->
          
          <a class="facebook share-sns" href="javascript:;" data-type="facebook">
            <i class="ri-facebook-circle-fill"></i>
          </a>
          <a class="twitter share-sns" href="javascript:;" data-type="twitter">
            <i class="ri-twitter-fill"></i>
          </a>
          <a class="google share-sns" href="javascript:;" data-type="google">
            <i class="ri-google-fill"></i>
          </a>
        </div>
      </div>
</div>

<div class="wx-share-modal">
    <a class="modal-close" href="javascript:;"><i class="ri-close-circle-line"></i></a>
    <p>扫一扫，分享到微信</p>
    <div class="wx-qrcode">
      <img src="//api.qrserver.com/v1/create-qr-code/?size=150x150&data=https://bodboy.gitee.io/blog/2020/09/14/Python-%E5%B8%B8%E7%94%A8%E7%9A%84%E5%B7%A5%E5%85%B7%E5%8C%85-%E5%90%8E%E6%9C%9F%E7%BB%A7%E7%BB%AD%E5%AE%8C%E5%96%84/" alt="微信分享二维码">
    </div>
</div>

<div id="share-mask"></div>
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/blog/tags/python/" rel="tag">python</a></li></ul>


    </footer>

  </div>

  
  
  <nav class="article-nav">
    
      <a href="/blog/2020/10/09/Quill%E7%BC%96%E8%BE%91%E5%99%A8%E8%87%AA%E5%AE%9A%E4%B9%89%E5%AD%97%E4%BD%93%E5%92%8C%E5%AD%97%E4%BD%93%E5%A4%A7%E5%B0%8F/" class="article-nav-link">
        <strong class="article-nav-caption">上一篇</strong>
        <div class="article-nav-title">
          
            Quill编辑器自定义字体和字体大小
          
        </div>
      </a>
    
    
      <a href="/blog/2020/09/14/Python%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0-%E4%BA%94-requets%E5%A4%9A%E7%A7%8D%E8%AF%B7%E6%B1%82%E5%8F%82%E6%95%B0/" class="article-nav-link">
        <strong class="article-nav-caption">下一篇</strong>
        <div class="article-nav-title">Python学习笔记(五) requets多种请求参数</div>
      </a>
    
  </nav>


  

  
  
<!-- valine评论 -->
<div id="vcomments-box">
    <div id="vcomments">
    </div>
</div>
<script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
<script src='https://cdn.jsdelivr.net/npm/valine@1.3.10/dist/Valine.min.js'></script>
<script>
    new Valine({
        el: '#vcomments',
        app_id: 'uW8QYGvvhWmNWdiwpznJ0GVa-gzGzoHsz',
        app_key: 'LrJhMzx9qEwcMV1DJjTI6f6C',
        path: window.location.pathname,
        notify: 'false',
        verify: 'false',
        avatar: '[object Object]',
        placeholder: '给我的文章加点评论吧~',
        recordIP: true
    });
    const infoEle = document.querySelector('#vcomments .info');
    if (infoEle && infoEle.childNodes && infoEle.childNodes.length > 0) {
        infoEle.childNodes.forEach(function (item) {
            item.parentNode.removeChild(item);
        });
    }
</script>
<style>
    #vcomments-box {
        padding: 5px 30px;
    }

    @media screen and (max-width: 800px) {
        #vcomments-box {
            padding: 5px 0px;
        }
    }

    #vcomments-box #vcomments {
        background-color: #fff;
    }

    .v .vlist .vcard .vh {
        padding-right: 20px;
    }

    .v .vlist .vcard {
        padding-left: 10px;
    }
</style>

  

  
  
  
  
  

</article>
</section>
      <footer class="footer">
  <div class="outer">
    <ul>
      <li>
        Copyrights &copy;
        2019-2021
        <i class="ri-heart-fill heart_icon"></i> panda
      </li>
    </ul>
    <ul>
      <li>
        
        
        
        Powered by <a href="https://hexo.io" target="_blank">Hexo</a>
        <span class="division">|</span>
        Theme - <a href="https://github.com/Shen-Yu/hexo-theme-ayer" target="_blank">Ayer</a>
        
      </li>
    </ul>
    <ul>
      <li>
        
        
        <span>
  <span><i class="ri-user-3-fill"></i>Visitors:<span id="busuanzi_value_site_uv"></span></s>
  <span class="division">|</span>
  <span><i class="ri-eye-fill"></i>Views:<span id="busuanzi_value_page_pv"></span></span>
</span>
        
      </li>
    </ul>
    <ul>
      
    </ul>
    <ul>
      <li>
        <!-- cnzz统计 -->
        
        <script type="text/javascript" src='https://s9.cnzz.com/z_stat.php?id=1278069914&amp;web_id=1278069914'></script>
        
      </li>
    </ul>
  </div>
</footer>
      <div class="float_btns">
        <div class="totop" id="totop">
  <i class="ri-arrow-up-line"></i>
</div>

<div class="todark" id="todark">
  <i class="ri-moon-line"></i>
</div>

      </div>
    </main>
    <aside class="sidebar on">
      <button class="navbar-toggle"></button>
<nav class="navbar">
  
  <div class="logo">
    <a href="/blog/"><img src="https://portrait.gitee.com/uploads/avatars/user/1007/3023420_bodboy_1578973210.png!avatar200" alt="小熊的博客"></a>
  </div>
  
  <ul class="nav nav-main">
    
    <li class="nav-item">
      <a class="nav-item-link" href="/blog/">主页</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/blog/archives">归档</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/blog/categories">分类</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/blog/tags">标签</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/blog/tags/%E6%97%85%E8%A1%8C/">旅行</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/blog/about">关于我</a>
    </li>
    
  </ul>
</nav>
<nav class="navbar navbar-bottom">
  <ul class="nav">
    <li class="nav-item">
      
      <a class="nav-item-link nav-item-search"  title="Search">
        <i class="ri-search-line"></i>
      </a>
      
      
      <a class="nav-item-link" target="_blank" href="/blog/atom.xml" title="RSS Feed">
        <i class="ri-rss-line"></i>
      </a>
      
    </li>
  </ul>
</nav>
<div class="search-form-wrap">
  <div class="local-search local-search-plugin">
  <input type="search" id="local-search-input" class="local-search-input" placeholder="Search...">
  <div id="local-search-result" class="local-search-result"></div>
</div>
</div>
    </aside>
    <script>
      if (window.matchMedia("(max-width: 768px)").matches) {
        document.querySelector('.content').classList.remove('on');
        document.querySelector('.sidebar').classList.remove('on');
      }
    </script>
    <div id="mask"></div>

<!-- #reward -->
<div id="reward">
  <span class="close"><i class="ri-close-line"></i></span>
  <p class="reward-p"><i class="ri-cup-line"></i>请我喝杯咖啡吧~</p>
  <div class="reward-box">
    
    <div class="reward-item">
      <img class="reward-img" src="/blog/images/alipay.jpg">
      <span class="reward-type">支付宝</span>
    </div>
    
    
    <div class="reward-item">
      <img class="reward-img" src="/blog/images/wechat.jpg">
      <span class="reward-type">微信</span>
    </div>
    
  </div>
</div>
    
<script src="/blog/js/jquery-2.0.3.min.js"></script>


<script src="/blog/js/lazyload.min.js"></script>


<script>
  try {
    var typed = new Typed("#subtitle", {
      strings: ['面朝大海，春暖花开', '愿你一生努力，一生被爱', '想要的都拥有，得不到的都释怀'],
      startDelay: 0,
      typeSpeed: 200,
      loop: true,
      backSpeed: 100,
      showCursor: true
    });
  } catch (err) {
  }

</script>




<script src="/blog/js/tocbot.min.js"></script>

<script>
  // Tocbot_v4.7.0  http://tscanlin.github.io/tocbot/
  tocbot.init({
    tocSelector: '.tocbot',
    contentSelector: '.article-entry',
    headingSelector: 'h1, h2, h3, h4, h5, h6',
    hasInnerContainers: true,
    scrollSmooth: true,
    scrollContainer: 'main',
    positionFixedSelector: '.tocbot',
    positionFixedClass: 'is-position-fixed',
    fixedSidebarOffset: 'auto'
  });
</script>



<script src="https://cdn.jsdelivr.net/npm/jquery-modal@0.9.2/jquery.modal.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jquery-modal@0.9.2/jquery.modal.min.css">
<script src="https://cdn.jsdelivr.net/npm/justifiedGallery@3.7.0/dist/js/jquery.justifiedGallery.min.js"></script>

<script src="/blog/dist/main.js"></script>



<!-- Root element of PhotoSwipe. Must have class pswp. -->
<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">

    <!-- Background of PhotoSwipe. 
         It's a separate element as animating opacity is faster than rgba(). -->
    <div class="pswp__bg"></div>

    <!-- Slides wrapper with overflow:hidden. -->
    <div class="pswp__scroll-wrap">

        <!-- Container that holds slides. 
            PhotoSwipe keeps only 3 of them in the DOM to save memory.
            Don't modify these 3 pswp__item elements, data is added later on. -->
        <div class="pswp__container">
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
        </div>

        <!-- Default (PhotoSwipeUI_Default) interface on top of sliding area. Can be changed. -->
        <div class="pswp__ui pswp__ui--hidden">

            <div class="pswp__top-bar">

                <!--  Controls are self-explanatory. Order can be changed. -->

                <div class="pswp__counter"></div>

                <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>

                <button class="pswp__button pswp__button--share" style="display:none" title="Share"></button>

                <button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>

                <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>

                <!-- Preloader demo http://codepen.io/dimsemenov/pen/yyBWoR -->
                <!-- element will get class pswp__preloader--active when preloader is running -->
                <div class="pswp__preloader">
                    <div class="pswp__preloader__icn">
                        <div class="pswp__preloader__cut">
                            <div class="pswp__preloader__donut"></div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
                <div class="pswp__share-tooltip"></div>
            </div>

            <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
            </button>

            <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
            </button>

            <div class="pswp__caption">
                <div class="pswp__caption__center"></div>
            </div>

        </div>

    </div>

</div>

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/default-skin/default-skin.min.css">
<script src="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe-ui-default.min.js"></script>

<script>
    function viewer_init() {
        let pswpElement = document.querySelectorAll('.pswp')[0];
        let $imgArr = document.querySelectorAll(('.article-entry img:not(.reward-img)'))

        $imgArr.forEach(($em, i) => {
            $em.onclick = () => {
                // slider展开状态
                // todo: 这样不好，后面改成状态
                if (document.querySelector('.left-col.show')) return
                let items = []
                $imgArr.forEach(($em2, i2) => {
                    let img = $em2.getAttribute('data-idx', i2)
                    let src = $em2.getAttribute('data-target') || $em2.getAttribute('src')
                    let title = $em2.getAttribute('alt')
                    // 获得原图尺寸
                    const image = new Image()
                    image.src = src
                    items.push({
                        src: src,
                        w: image.width || $em2.width,
                        h: image.height || $em2.height,
                        title: title
                    })
                })
                var gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, {
                    index: parseInt(i)
                });
                gallery.init()
            }
        })
    }
    viewer_init()
</script>


<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
      tex2jax: {
          inlineMath: [ ['$','$'], ["\\(","\\)"]  ],
          processEscapes: true,
          skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
      }
  });

  MathJax.Hub.Queue(function() {
      var all = MathJax.Hub.getAllJax(), i;
      for(i=0; i < all.length; i += 1) {
          all[i].SourceElement().parentNode.className += ' has-jax';
      }
  });
</script>

<script src="https://cdn.jsdelivr.net/npm/mathjax@2.7.6/unpacked/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script>
  var ayerConfig = {
    mathjax: true
  }
</script>




<script src="/blog/js/busuanzi-2.3.pure.min.js"></script>



<script type="text/javascript" src="https://js.users.51.la/20544303.js"></script>

  
<script src="/blog/js/clickLove.js"></script>



<!-- 复制 -->



    
    <div id="music">
    
    
    
    <iframe frameborder="no" border="1" marginwidth="0" marginheight="0" width="200" height="52"
        src="//music.163.com/outchain/player?type=2&id=1297802566&auto=1&height=32"></iframe>
</div>

<style>
    #music {
        position: fixed;
        right: 15px;
        bottom: 0;
        z-index: 998;
    }
</style>
    
  </div>
</body>

</html>